﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using QD.Snapshot.Core.BLL;
using System.Windows.Forms;
using QD.Snapshot.Core.Util;
using Pigeon.Utility;
using QD.Snapshot.Core.Config;
using System.Threading.Tasks;

namespace QD.Snapshot
{
    public class Work
    {
        public static Thread Begin_BD(TextBox textBox)
        {
            SearchBase searchBase = new Search_Baidu(textBox, 10);
            return Begin(textBox, searchBase);
        }

        public static Thread Begin_360(TextBox textBox)
        {
            SearchBase searchBase = new Search_360(textBox, 10);
            return Begin(textBox, searchBase);
        }

        public static Thread Begin_SG(TextBox textBox)
        {
            SearchBase searchBase = new Search_Sogou(textBox, 10);
            return Begin(textBox, searchBase);
        }

        public static Thread Begin_WX(TextBox textBox)
        {
            SearchBase searchBase = new Search_Weixin(textBox, 10);
            return Begin(textBox, searchBase);
        }

        public static Thread Begin_Bing(TextBox textBox)
        {
            SearchBase searchBase = new Search_Bing(textBox, 10);
            return Begin(textBox, searchBase);
        }

        public static Thread Begin_GuoSou(TextBox textBox)
        {
            SearchBase searchBase = new Search_GuoSou(textBox, 10);
            return Begin(textBox, searchBase);
        }

        public static Thread Begin_ShenMa(TextBox textBox)
        {
            SearchBase searchBase = new Search_ShenMa(textBox, 10);
            return Begin(textBox, searchBase);
        }


        static Thread Begin(TextBox textBox, SearchBase searchBase)
        {
            Thread thread = new Thread(new ThreadStart(delegate()
            {
                while (true)
                {
                    searchBase.Search();
                    EchoHelper.ShowMessage(textBox, "搜索结束");
                }
            }), 0);
            thread.IsBackground = true;
            thread.Start();
            return thread;
        }
    }
}